package com.lovo.total.frame;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.lovo.common.model.CutPageBean;
import com.lovo.emp.frame.EmpAddDialog;
import com.lovo.emp.frame.EmpPanel;
import com.lovo.emp.frame.EmpShowDialog;
import com.lovo.emp.frame.EmpUpdateDialog;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoCutPage;
import com.lovo.netCRM.component.LovoTable;
import com.lovo.netCRM.component.LovoTitleLabel;
import com.lovo.netCRM.component.LovoTitlePanel;
import com.lovo.netCRM.component.LovoTxt;
import com.lovo.total.service.IAreaTotalService;
import com.lovo.total.service.impl.AreaTotalServiceImpl;

/**
 * 地区统计主面板
 * @author 白德柯
 *
 */
public class AreaTotalPanel extends JPanel{


	/**地区统计表格组件*/
	private LovoTable areaTotalTable;
	/**窗体组件*/
	private JFrame jf;

	private IAreaTotalService areaTotalService = new AreaTotalServiceImpl();

	/**分页对象*/
	private LovoCutPage cutPage;

	public AreaTotalPanel(JFrame jf){
		this.jf = jf;
		this.setLayout(null);
		this.init();
	}
	/**
	 * 初始化
	 *
	 */
	private void init() {
		new LovoTitleLabel("地 区 统 计",this);
		this.initTable();
		this.initData();
	}
	/**
	 * 初始化数据
	 */
	public void initData(){
		this.updateTable(1);
	}
	
	

	
	//-------------------------------------------------
	/**
	 * 初始化表格
	 *
	 */
	private void initTable() {
		areaTotalTable = new LovoTable(this,
				new String[]{"城市名称","录入学校","接洽中学校","待审学校","审核未通过学校","推广开展学校"},
				new String[]{"cityName","schoolCount","inContactCount","pendingCount","failedCount","passedCount"},//地区统计实体属性名数组
				"");//主键属性名 
		areaTotalTable.setSizeAndLocation(20, 90, 700, 300);
		// 分页
		cutPage = new LovoCutPage(20,400,this) {
			@Override
			public void clickEvent(int page) {
				updateTable(page);
			}
		};
	}
	
	
	/**
	 * 更新表格数据
	 */
	private void updateTable(int page){
		CutPageBean cutPageBean = areaTotalService.findByItem(page);
		//更新表格
		areaTotalTable.updateLovoTable(cutPageBean.getList());
		if(page == 1){
			cutPage.setTotalPage(cutPageBean.getTotalPage());
		}
	}

}
